#include<utility>
#include<cstdio>
#include<set>
using namespace std;
typedef pair<int,int> PII;
int n,len=1e9,res=1e9;
multiset<PII> s;
int main(){
	freopen("stone.in","r",stdin);
	freopen("stone.out","w",stdout);
	scanf("%d",&n);
	while(n--){
		char op=getchar();
		while((op!='A')&&(op!='R'))
			op=getchar();
		PII seg;
		scanf("%d%d",&seg.first,&seg.second);
		if(op=='A'){
			s.insert(seg);
			for(PII t:s){
				int l,ans;
				if(t.first<seg.first){
					if(t.second<seg.first)
						l=0;
					else
						l=t.second-seg.first;
					if(t.second>seg.second)
						ans=t.second-t.first;
					else
						ans=seg.second-t.first;
				}
				else{
					if(seg.second<t.first)
						l=0;
					else
						l=seg.second-t.first;
					if(seg.second>t.second)
						ans=seg.second-seg.first;
					else
						ans=t.second-seg.first;
				}
				if((l<len)||((l==len)&&(ans<res))){
					len=l;	res=ans;
				}
			}
		}
		if(op=='R'){
			s.erase(s.find(seg));
			len=1e9;
			res=1e9;
			for(PII t:s)
				for(PII seg:s){
					int l,ans;
					if(t.first<seg.first){
						if(t.second<seg.first)
							l=0;
						else
							l=t.second-seg.first;
						if(t.second>seg.second)
							ans=t.second-t.first;
						else
							ans=seg.second-t.first;
					}
					else{
						if(seg.second<t.first)
							l=0;
						else
							l=seg.second-t.first;
						if(seg.second>t.second)
							ans=seg.second-seg.first;
						else
							ans=t.second-seg.first;
					}
					if((l<len)||((l==len)&&(ans<res))){
						len=l;	res=ans;
					}
				}
		}
		printf("%d\n",res);
	}
	return 0;
}
